package com.nlx.notes.module.controller;

import com.nlx.notes.module.bean.dto.sms.SendSmsDTO;
import com.nlx.notes.module.bean.dto.sms.SmsValidDTO;
import com.nlx.notes.module.core.util.JSONUtils;
import com.nlx.notes.module.service.sms.SmsManageService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping(value = "/sms")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class SmsController {

    final SmsManageService smsManageService;


    /**
     * 发送短信验证码
     * @param sendSmsDTO 参数
     * @return boolean
     */
    @PostMapping(value = "/send-sms")
    public String sendSms(@RequestBody @Validated SendSmsDTO sendSmsDTO) {
        log.info("发送短信，入参：{}", JSONUtils.toString(sendSmsDTO));
        return smsManageService.sendSms(sendSmsDTO);
    }

    /**
     * 验证码校验
     * @param smsValidDTO
     * @return
     */
    @PostMapping(value = "/valid-sms")
    public boolean validSms(@RequestBody SmsValidDTO smsValidDTO) {
        log.info("验证短信验证码，入参：{}", JSONUtils.toString(smsValidDTO));
        return true;
    }

}
